from imposm.parser import OSMParser

class roads(object):
   road_node=[]
   def ways(self,ways): 
       for osm_id,tags,ref in ways:
		if 'highway' in tags:
                           for i in ref:
                             self.road_node.append(i)
   def coords(self,coords):
       self.road_node.sort()
       self.road_node=list(set(self.road_node))
       file1=open("road.b","w")
       for osm_id,lon,lat in coords:
		for i in self.road_node:
                     if i == osm_id:
                           line=str(osm_id)+";"+str(lat)+";"+str(lon)
                           file1.write(line)
                           file1.write("\n")
       file1.close()  

road_scraper = roads()

p = OSMParser(concurrency=1, ways_callback=road_scraper.ways)
p.parse('iise.osm')
t = OSMParser(concurrency=1, coords_callback=road_scraper.coords)
t.parse('iise.osm')


#print road_scraper.road_node
